export type Data<T> = {
  code: number
  info: string
  data: T
  // token?: string
}
type NewsListResponse = Data<{
  list: {
    id: number
    title: string
    source: string
    link: string
    createTime: Date
  }[]
}>

/**
 * 查询新闻列表
 * @returns 新闻数据列表
 */
export const queryNews = () => {
  return uni.request({
    url: '/news/queryNews',
    method: 'GET',
  })
}

/**
 * 查询学习日历
 * 获取用户的学习日历数据
 */
export const queryStudyCalendar = () => {
  const token = uni.getStorageSync('token')
  return uni.request({
    url: '/api/studycalendar/query',
    method: 'GET',
    header: {
      token: token,
    },
  })
}
